﻿using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Csla;

namespace Model
{
    [Serializable()]
    public class RBangLuongBOCollection : Csla.BusinessListBase<RBangLuongBOCollection, RBangLuongBO>
    {
        #region BindingList Overrides
        protected override object AddNewCore()
        {
            RBangLuongBO _BangLuongBO = RBangLuongBO.NewChildRBangLuongBO();
            OnAddingNew(new System.ComponentModel.AddingNewEventArgs(_BangLuongBO));
            _BangLuongBO.STT0 = this.Count + 1;
            Add(_BangLuongBO);
            return _BangLuongBO;
        }
        #endregion BindingList Overrides
        //==========================================================================

        #region Factory Methods
        private RBangLuongBOCollection()
        {
        }

        public static RBangLuongBOCollection NewRBangLuongBOCollection()
        {
            return new RBangLuongBOCollection();
        }

        public static RBangLuongBO NewRBangLuongBO()
        {
            return RBangLuongBO.NewChildRBangLuongBO();
        }

        public static RBangLuongBOCollection GetRBangLuongBOCollection()
        {
            SPParam spParam = new SPParam("BangLuongID", "ASC", "WHERE DELE=0");
            return DataPortal.Fetch<RBangLuongBOCollection>(spParam);
        }

        public static RBangLuongBOCollection GetRBangLuongBOCollection(bool getDeleted)
        {
            SPParam spParam = new SPParam("BangLuongID", "ASC", "");
            return DataPortal.Fetch<RBangLuongBOCollection>(spParam);
        }

        public static RBangLuongBOCollection GetRBangLuongBOCollection(string where)
        {
            SPParam spParam = new SPParam("BangLuongID", "ASC", "WHERE DELE=0" + (where != "" ? " AND " : "") + where);
            return DataPortal.Fetch<RBangLuongBOCollection>(spParam);
        }

        public static RBangLuongBOCollection GetRBangLuongBOCollection(string where, bool getDeleted)
        {
            SPParam spParam = new SPParam("BangLuongID", "ASC", (where != "" ? "WHERE " : "") + where);
            return DataPortal.Fetch<RBangLuongBOCollection>(spParam);
        }

        public static RBangLuongBOCollection GetRBangLuongBOCollection(string where, string orderByColumn)
        {
            SPParam spParam = new SPParam((orderByColumn == "" ? "BangLuongID" : orderByColumn), "ASC", "WHERE DELE=0" + (where != "" ? " AND " : "") + where);
            return DataPortal.Fetch<RBangLuongBOCollection>(spParam);
        }

        public static RBangLuongBOCollection GetRBangLuongBOCollection(string where, string orderByColumn, bool getDeleted)
        {
            SPParam spParam = new SPParam((orderByColumn == "" ? "BangLuongID" : orderByColumn), "ASC", (where != "" ? "WHERE " : "") + where);
            return DataPortal.Fetch<RBangLuongBOCollection>(spParam);
        }

        public static RBangLuongBOCollection GetRBangLuongBOCollection(string where, string orderByColumn, string orderByExpression)
        {
            SPParam spParam = new SPParam((orderByColumn == "" ? "BangLuongID" : orderByColumn), (orderByExpression == "" ? "ASC" : orderByExpression), "WHERE DELE=0" + (where != "" ? " AND " : "") + where);
            return DataPortal.Fetch<RBangLuongBOCollection>(spParam);
        }

        public static RBangLuongBOCollection GetRBangLuongBOCollection(string where, string orderByColumn, string orderByExpression, bool getDeleted)
        {
            SPParam spParam = new SPParam((orderByColumn == "" ? "BangLuongID" : orderByColumn), (orderByExpression == "" ? "ASC" : orderByExpression), (where != "" ? "WHERE " : "") + where);
            return DataPortal.Fetch<RBangLuongBOCollection>(spParam);
        }
        #endregion Factory Methods
        //==========================================================================

        #region Criteria
        [Serializable()]
        private class Criteria
        {
            public Criteria()
            {
            }
        }

        [Serializable()]
        public class FilterCriteria
        {
            public FilterCriteria()
            {
            }
        }
        #endregion Criteria
        //==========================================================================

        #region Fetch
        [Transactional(TransactionalTypes.TransactionScope)]
        private void DataPortal_Fetch(SPParam spParam)
        {
        }
        #endregion Fetch
        //==========================================================================

        #region Update
        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Update()
        {
            Update();
        }

        internal void Update()
        {
        }
        #endregion Update
        //==========================================================================

        #region Business Method
        public RBangLuongBO GetRBangLuongBO(int _BangLuongID)
        {
            int length = this.Count;
            for (int i = 0; i < length; i++)
                if (this[i].BangLuongID == _BangLuongID)
                    return this[i];

            return null;
        }

        public void Remove(int BangLuongID)
        {
            int length = this.Count;
            for (int i = 0; i < length; i++)
            {
                if (this[i].BangLuongID == BangLuongID)
                {
                    try
                    {
                        this.RemoveAt(i);
                    }
                    catch { }
                    break;
                }
            }
        }
        #endregion Business Method
        //==========================================================================
    }
}
